package my.algo;

/**
 * n | m & n = n
 * n | m & m = m
 * (x | y | z) & x = x
 * (x | y | z) & y = y
 *
 * n = 2 ** i ==> n & (n - 1) = 0
 */
public class 与和或 {

    public static void main(String[] args) {
        System.out.println(0 | 2);
        System.out.println(2 & 0);
        System.out.println(2 & 2);

        System.out.println("------");

        System.out.println(2 | 4);
        System.out.println(6 & 2);
        System.out.println(6 & 4);

        System.out.println("------");

        System.out.println(4 | 8);
        System.out.println(12 & 4);
        System.out.println(12 & 8);

        System.out.println("------");

        System.out.println(0 | 2 | 4 | 8);
        System.out.println(14 & 0);
        System.out.println(14 & 2);
        System.out.println(14 & 4);
        System.out.println(14 & 8);

        System.out.println("------");
        System.out.println(2 & 1);
        System.out.println(4 & 3);
        System.out.println(8 & 7);
        System.out.println(16 & 15);
        System.out.println(32 & 31);
    }
}
